import Vue from 'vue'
import Main from './Main'

const ToastConstructor = Vue.extend(Main)

export const Toast = (options) => {
  const instance = new ToastConstructor({
    el: document.createElement('div'),
    data() {
      return {
        text: options.text,
        type: options.type
      }
    }
  })
  document.body.appendChild(instance.$el)

  setTimeout(() => {
    document.body.removeChild(instance.$el)
    instance.$destroy()
  }, options.duration || 3000)
}
